package function

import java.io.{File, FileWriter, PrintWriter}
import java.util.Date
import scala.io.{BufferedSource, Source}
import java.text.SimpleDateFormat
object FileIo {
  def main(args: Array[String]): Unit = {
    /**
     * 从文件中读取数据
     */
//    val read: BufferedSource = Source.fromFile("F:\\ComputeDb\\XUANZE\\PROD.XPA.ATSN.MAN.MESSAGECHECKER.EQUIPMENTSTATECHANGE.PUB.V1")
//    println(read.foreach(print))
     val a="测试"
    val b="ceshi"
    val simpdate = new Date()
    val simpleDateFormattime = new SimpleDateFormat("yyyy-MM-dd")
    val str: String = simpleDateFormattime.format(simpdate)
    /**
     * 将数据写入到文件中
     */
    val writer = new PrintWriter(new FileWriter(s"F:\\Project\\scala_studys\\scala_studys\\src\\biji\\${str}.log",true))
    writer.write(s"写入日期：${new Date()}，写入了：${a}\n" +
      s"${b}\n")
    writer.close()

  }

}
